package net.cyan.thunwind;

import java.sql.SQLException;

/**
 * 
 * @author camel
 * @date 2008-6-21
 */

public class PersistenceSQLException extends PersistenceException
{
    private String sql;

    public PersistenceSQLException(String sql, SQLException cause)
    {
        super("execute sql failed:" + cause.getMessage() + ",sql:" + sql + ",errorCode:" + cause.getErrorCode(), cause);
        this.sql = sql;
    }

    public PersistenceSQLException(String message, String sql, SQLException cause)
    {
        super(message + ",sql:" + sql + ",errorCode:" + cause.getErrorCode(), cause);
        this.sql = sql;
    }

    public String getSql()
    {
        return sql;
    }

    public int getErrorCode()
    {
        return ((SQLException) getCause()).getErrorCode();
    }
}